﻿/**
 * Created by zzw on 2016/5/17.
 * 通用的ajax调用类
 */

var  serviceAddress = {
    Address:"http://localhost:8080"
};
(function ($) {
    $.fn.serviceInvoke = function (address,page, method, paramObj, CallBackFunction) {
       var url = address + "/" +page+"/"+ method;
        $.ajax({
            type: "POST",
            url:url,
            async: false,
            data: {"reqData":paramObj},
            dataType: "json",
            success: function (_result) {
                try {
                    if(_result!=null){
                        CallBackFunction(_result);
                    }else{
                        CallBackFunction(null);
                    }
                } catch (e) {
                    //alert(e)
                }
            },
            error: function (_result) {
                console.log(_result);
            },
            complete : function(XMLHttpRequest,status){
                if(status=='timeout'){
                    ajaxTimeoutTest.abort();
                    alert("登录超时");
                }
            }
        });
    }
})($);